<template>
	<view>

		<view class="bg">

			<view class="lineGray1 line">
				<view class="lineBlack " style="flex-grow: 3;"></view>
				<view class="bigEmpty"></view>
			</view>
			<input type="password" v-model="password" class="underline-input" focus placeholder="输入密码" />
			<input type="password" v-model="password1" class="underline-input" focus placeholder="输入确认密码" />

			<button type="primary" v-show="name&&password&&password1 " class="marginTop3"
				@click="register()">确认修改</button>
			<button v-show="!(name&&password&&password1)" class="marginTop3" @click="register">确认修改</button>

		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: "",
				password: "",
				password1: "",
				phone: ""
			}
		},
		onShareAppMessage(res) {
			return {
				title: '设辑-产品设计智能生成AI',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/black-logo.png'
			}
		},
		// 自定义页面的分享到朋友圈
		onShareTimeline(res) {
			return {
				title: '设辑-产品设计智能生成AI',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/black-logo.png'
			}
		},
		onLoad: function(query) {

			this.phone = query.phone;

		},
		methods: {
			register: function() {

				if (!this.password) {
					uni.showToast({
						title: "密码不能为空"
					})
					return
				}

				if (this.password != this.password1) {
					uni.showToast({
						title: "密码不一致"
					})
					return
				}

				const url = getApp().globalData.apiUrl + "/api/v1/user/updatePassword";
				const that = this;
				console.log()
				uni.request({
					url: url,
					data: {
						password: this.password,
						name: this.name,
						phone: this.phone
					},
					method: 'PUT',
					success: (res) => {

						console.log(res)
						if (res.data.code == 0) {
							uni.showToast({
								icon: 'success',
								title: "修改成功"
							})
							
						} else {
							uni.showToast({
								icon: 'error',
								title: res.data.message
							})
						}

					}
				});
			},
			login: function() {
				console.log("login")
				uni.navigateTo({
					url: "/pages/Login/Login"
				})
			}
		}
	}
</script>

<style>
	@import url("../../common/uni.css");


	.lineBlack {

		height: 8px;
		background: #282828;
		border-radius: 7px 7px 7px 7px;
	}

	.lineGray1 {

		height: 8px;
		background: #D9DBE0;
		border-radius: 7px 7px 7px 7px;

	}



	button[type=primary] {
		background-color: #282828;
	}

	.bigMarginTop {
		margin-top: 50upx;
	}

	.image1 {
		width: 198.85px;
		height: 117.76px;
	}

	.image2 {
		width: 195.67px;
		height: 36.31px;
	}

	.image3 {
		margin-left: 100upx;
		width: 67.63px;
		height: 41.17px;
	}

	.bigText {
		font-size: 50px;
		font-weight: normal;
		line-height: 50px;
		text-align: center;
		letter-spacing: 0px;
		color: #FFFFFF;
	}

	.input1 {
		margin-top: 50upx;
		color: #FFFFFF;
	}

	.bg {
		height: 100vh;
		padding: 50upx;
		background: #FFFFFF;
	}
</style>